home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CDecimalText 1.0 / CDecimalText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.2 KB  |  80 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CDecimalText.h
  3.  
  4.         Interface for CDecimalText class
  5.         
  6.     SUPERCLASS = CDialogText
  7.     
  8.     Copyright © 1993 Michael Abramowicz. All rights reserved.
  9.     
  10.  
  11.  ******************************************************************************/
  12.  
  13. #pragma once
  14.  
  15. #include "CDialogText.h"
  16.  
  17. typedef struct tDecimalTextTemp
  18. {
  19.     tDialogTextTemp dlgTextTmp;
  20.     long             minValue;
  21.     long             maxValue;
  22.     long             defaultValue;
  23.     short             decimalPlaces;
  24.     
  25. } tDecimalTextTemp, *tDecimalTextTempP;
  26.  
  27. typedef enum {
  28.     kValid = 1,
  29.     kNonNumeric,
  30.     kNonIntegral,
  31.     kTooManyDecimalPlaces,
  32.     kOutOfRange,
  33.     kOtherReason } Validity;
  34.     
  35. class CDecimalText : public CDialogText
  36. {
  37. public:
  38.  
  39.     void     IDecimalText( CView *anEnclosure, CView *aSupervisor,
  40.                     short aWidth, short aHeight,
  41.                     short aHEncl, short aVEncl,
  42.                     SizingOption aHSizing, SizingOption aVSizing,
  43.                     short aLineWidth);
  44.                     
  45.     virtual void     IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
  46.                             Ptr viewData);
  47.     void            SpecifyDecimalPlaces( short numPlaces, Boolean doValidate);
  48.     short            GetDecimalPlaces(void);
  49.     virtual void    SpecifyRange( long aMinimum, long aMaximum);
  50.     virtual void    SpecifyDefaultValue( long aDefaultValue);
  51.     
  52.     virtual void    SetDecValue( double aValue);
  53.     virtual double    GetDecValue( void);    
  54.  
  55.     virtual void     ReportInvalidText( short strIndex);
  56.     virtual Boolean Validate( void);
  57.     
  58.     virtual void    DoCommand(long theCommand);
  59.  
  60. protected:
  61.  
  62.     long     minValue;        // minimum valid value
  63.     long     maxValue;        // maximum valid value
  64.     long    defaultValue;    // default value if text empty. If 
  65.                             // CDialogText::isRequired is FALSE, then
  66.                             // empty text is considered valid and default
  67.                             // value is returned by GetIntValue.
  68.     short    decimalPlaces;    // The maximum number of decimal places that
  69.                             // will be displayed.
  70.                             
  71.     virtual void ConvertToDecimal( double *decValue, Validity *valid);
  72. };
  73.  
  74.     // indices into validation error STR# resource for CDecimalText
  75.  
  76. #define        validateNonNumeric        3    // text is non-numeric
  77. #define        validateNonIntegral        4    // text is non-integral
  78. #define        validateDecPlaces        5    // too many decimal places
  79. #define        validateOutOfRange        6    // number is out of rangeΩ
  80.